package com.yungee.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yungee.base.entity.JsonHistory;
import com.yungee.base.mapper.JsonHistoryMapper;
import com.yungee.base.service.JsonHistoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author auto-generate
 * @since 2024-05-11
 */
@Service
public class JsonHistoryServiceImpl extends ServiceImpl<JsonHistoryMapper, JsonHistory> implements JsonHistoryService {
    @Autowired
    private JsonHistoryMapper jsonHistoryMapper;
    @Override
    public JsonHistory selectByMd5(String md5) {
        QueryWrapper<JsonHistory> query = new QueryWrapper<>();
        query.eq("md5",md5);
        query.last("limit 1");
        return jsonHistoryMapper.selectOne(query);
    }

    public JsonHistory getLatestChangeJson() {
        QueryWrapper<JsonHistory> query = new QueryWrapper<>();
        query.orderByDesc("update_time");
        query.last("limit 1");
        return jsonHistoryMapper.selectOne(query);
    }
}
